# Contributor: Andy Li <andy@onthewings.net>
# Maintainer: Andy Li <andy@onthewings.net>
pkgname=ocaml-qcheck
_pkgname=qcheck
pkgver=0.18.1
pkgrel=1
pkgdesc="QuickCheck inspired property-based testing for OCaml"
url="https://github.com/c-cube/qcheck"
arch="all !riscv64"  # limited by ocaml aport
license="BSD-2-Clause"
depends="ocaml-runtime"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="dune ocaml ocaml-findlib ocaml-ounit-dev ocaml-seq-dev ocaml-stdlib-shims"
options="!check"	# requires alcotest
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/c-cube/qcheck/archive/v$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	export OCAMLPATH=/usr/lib/ocaml
	dune build @install \
		-p qcheck,qcheck-core,qcheck-ounit \
		--no-buffer --verbose
}

check() {
	dune runtest --no-buffer
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--prefix=/usr \
		--libdir=/usr/lib/ocaml \
		qcheck qcheck-core qcheck-ounit

	# There's just a readme and changelog.
	rm -Rf "$pkgdir"/usr/doc
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find usr/lib/ocaml \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
6fd5fd4348ed6a48a8f64a466fedd07374eaf23d516b3c250ebad2a32ddbca3ae4ad9c84fe1112858075df46c119cd6550205a4228a553b014d135581f024ded  ocaml-qcheck-0.18.1.tar.gz
"
